package com.example.his.api;

import com.example.his.api.async.InitializeWorkAsync;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@SpringBootApplication
@ServletComponentScan
@EnableAsync    // 开启异步线程
@ComponentScan("com.example.*")
@MapperScan("com.example.his.api.db.dao")
@EnableCaching  // 开启springCache二级缓存
@EnableScheduling  // 启用定时服务
public class HisApiApplication {
  @Resource
  private InitializeWorkAsync initializeWorkAsync;
  
  public static void main(String[] args) {
    SpringApplication.run(HisApiApplication.class, args);
  }
  
  //  项目启动的时候执行
  @PostConstruct
  public void init() {
    initializeWorkAsync.init();
  }
  
}
